﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace docmgr.WinForm
{
    public partial class InputMessagebox : Form
    {

        public String password = "";
        public Boolean isTrue = false;
        private bool p=false;
        public InputMessagebox()
        {
            InitializeComponent();
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));
        }

        public InputMessagebox(bool p)
        {
            // TODO: Complete member initialization
            InitializeComponent();
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));
  
            this.p = p;
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("不能为空");
                return;
            }
            password = textBox1.Text;
            isTrue = (Common.EncryptCode(password) == (string)Common.curUser.Rows[0]["Password"]);

            if (p!=true&&isTrue)//这个p是为了判断是不是自己的密码判断。
            {
                Common.sessionLogin = true;
                Common.sessionTimer.Start();
            }

            this.Close();
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("不能为空");
                    return;
                }
                password = textBox1.Text;
                isTrue = (Common.EncryptCode(password) == (string)Common.curUser.Rows[0]["Password"]);

                if (p != true && isTrue)//这个p是为了判断是不是自己的密码判断。
                {
                    Common.sessionLogin = true;
                    Common.sessionTimer.Start();
                }

                this.Close();
            }
        }
    }
}
